<?php

class PhoneNo1 implements VarsInterface{
	
	private static $instanse;
	private $tpl_path;
	private $value;
	private $dataPath;
	
	private function __construct(){
		$this->tpl_path = dirname(__FILE__) . '/tpl/phoneNo/';
		$this->dataPath = '_data/vars/' . get_class($this) . '.txt';
		
		if(file_exists($this->dataPath)){
			$this->value = file_get_contents($this->dataPath);
		}
	}
	
	public function getName(){
		return "Телефон";
	}
	public function out(){
		return $this->value;
	}
	public function backendSave(){
		
		if(isset($_POST['class']) && $_POST['class'] == get_class($this)){
			
			$this->value = $_POST['value'];
			if(!file_exists('_data/vars')){
				mkdir('_data/vars', 0775);
			}
			
			file_put_contents($this->dataPath, $this->value);
		}
	}
	public function getBackendOut(){
		
		return strtr(file_get_contents($this->tpl_path . "form.htm"),
			array(
			'{CLASS}' => get_class($this),
			'{VALUE}' => $this->value,
				)
			);
			
	}
	
	public static function getInstanse(){
		return is_null(self::$instanse)?new PhoneNo1():$this->instanse;
	}
}